perm filename PROB6.PUB[LSP,JRA]4 blob
sn#095100 filedate 1974-03-28 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00002 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 .SS(Problems)
C00007 ENDMK
C⊗;
.SS(Problems)
%2I.%* This problem deals with the function %3value%* from {yonss(P2)}.
1. Show how to extend %3 value%* to handle binary and unary minus.
2. Write a function, %3instantiate%* which will take two arguments,
one representing a set of variables and values; the other representing
a polynomial. %3instantiate%* is to return a representation of the
polynomial which would result from substituting the values for the variables.
3. It would be nice if we could represent expressions like 2+3+4 as
%3(PLUS#2#3#4)%* rather than %3(PLUS#(PLUS#2#3)#4)%* or %3(PLUS#2(PLUS#3#4))%*;
or represent 2*3*4+5+6 as %3(PLUS#(TIMES#2#3#4)#5#6)%*.
Write a new version of %3value%* which can evaluate such n-ary representations
of + and *.
.NEXT PAGE;
.SS(The great mothers,,P39:)
.BEGIN CENTERIT;TABIT3(10,25,36);
.GROUP;
←%2I. The Great Mother of All Functions!!! (⊗→%3tgmoaf%*↔←)
%3
\tgmoaf[x] <= \[atom[x] →\[eq[x ;T] → T;
\\\ eq[x;NIL] → NIL;
\\\ T → TRYAGAINNEXTWEEK];
\\ eq[car[x];QUOTE] → cadr[x];
\\ eq[car[x];CAR] → car[tgmoaf[cadr[x]]];
\\ eq[car[x];CDR] → cdr[tgmoaf[cadr[x]]];
\\ eq[car[x];CONS] → cons[tgmoaf[cadr[x]];tgmoaf[caddr[x]]];
\\ eq[car[x];ATOM] → atom[tgmoaf[cadr[x]]];
\\ eq[car[x];EQ] → eq[tgmoaf[cadr[x]];tgmoaf[caddr[x]]];
\\ T → TRYAGAINNEXTWEEK]
%1
.APART
.GROUP
Evaluate the following:
%21.%3 tgmoaf[T]
%22.%3 tgmoaf[A]
%23.%3 tgmoaf[(CAR(QUOTE(A . B)))]
%24.%3 tgmoaf[(CDR (QUOTE (A B)))]
%25.%3 tgmoaf[(EQ (CAR (QUOTE (A . B)))(QUOTE A))]
%26.%3 tgmoaf[(EQ (CAR (QUOTE (A . B))) A)]
%27.%3 tgmoaf[(ATOM (CAR (QUOTE (A B))))]
.APART
.GROUP
←%2II. The Great Mother of All Functions Revisited!!!(⊗→%3tgmoafr%*↔←)
%3
\tgmoafr[x] <= \[atom[x] →\[eq[x;T] → T;
\\\ eq[x;NIL] → NIL;
\\\ T → TRYAGAINNEXTWEEK];
\\ eq[car[x];QUOTE] → cadr[x];
\\ eq[car[x];CAR] → car[tgmoafr[cadr[x]]];
\\ eq[car[x];CDR] → cdr[tgmoafr[cadr[x]]];
\\ eq[car[x];CONS] → cons[tgmoafr[cadr[x]];tgmoafr[caddr[x]]];
\\ eq[car[x];ATOM] → atom[tgmoafr[cadr[x]]];
\\ eq[car[x];EQ] → eq[tgmoafr[cadr[x]];tgmoafr[caddr[x]]];
\\ eq[car[x];COND] → evcond[cdr[x]];
\\ T → TRYAGAINNEXTWEEK]
.APART
.GROUP
\evcond[x] <=\[tgmoafr[caar[x]] → tgmoafr[cadar[x]];
\\ T → evcond[cdr[x]] ]
.APART
.GROUP
%1
Evaluate the following:
%21.%3 tgmoafr[T]
%22.%3 tgmoafr[(CDR (QUOTE (A B)))]
%23.%3 tgmoafr[(EQ (CAR (QUOTE (A . B))) (QUOTE A))]
%24.%3 tgmoafr[(COND((EQ (CAR (QUOTE (A . B)))(QUOTE A))(QUOTE FOO)))]
%25.%3 tgmoafr[(COND((ATOM (QUOTE (A)))(QUOTE FOO))(T(QUOTE BAZ)))]
.APART
←Coming soon: %2Son of Great Mother !!%*
.END